﻿using B.S.Data.MES.API.Applications.BaseData.Command.ProductCommand;
using B.S.Domain.CangKu;
using B.S.Requst;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Security.Claims;

namespace B.S.Data.MES.API.Controllers
{
    /// <summary>
    /// 成品控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ProductController : ControllerBase
    {
        /// <summary>
        /// 中介者
        /// </summary>
        private readonly IMediator _mediator;
        /// <summary>
        /// 日志
        /// </summary>
        private readonly ILogger<ProductController> _logger;
        public ProductController(IMediator mediator, ILogger<ProductController> logger)
        {
            _mediator = mediator;
            _logger = logger;
        }
        /// <summary>
        /// 添加成品信息
        /// </summary>
        /// <param name="command">命令</param>
        /// <returns>返回任务</returns>
        [HttpPost]
        public Task<APIRequst<int>> AddProduct(AddGoodCommand command)
        {
          
            return _mediator.Send(command);
        }
        /// <summary>
        /// 获取成品信息
        /// </summary>
        /// <param name="command">命令</param>
        /// <returns>返回任务</returns>
        [HttpGet]
        public Task<APIRequst<APIPageing<List<Finished_ProductTest>>>> GetProduct([FromQuery] GetGoodCommand command)
        {
            return _mediator.Send(command);
        }
        /// <summary>
        /// 进行检验
        /// </summary>
        /// <param name="finisheId">编号</param>
        /// <returns>返回任务</returns>
        [HttpDelete]
        public Task<APIRequst<int>> UpdateProduct(int finisheId)
        {
            QueryGoodCommand command = new QueryGoodCommand();
            command.finisheId = finisheId;
            return _mediator.Send(command);

        }
    }
}
